package com.tarena.lbs.message.web.service;

import com.alibaba.nacos.common.utils.CollectionUtils;
import com.tarena.lbs.message.web.repository.DynamicFieldRepository;
import com.tarena.lbs.pojo.message.po.DynamicFieldsPO;
import com.tarena.lbs.pojo.message.vo.DynamicFieldsVO;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DynamicFieldsService {
    @Autowired
    private DynamicFieldRepository dynamicFieldRepository;
    public List<DynamicFieldsVO> selectAll() {
        List<DynamicFieldsPO> pos=dynamicFieldRepository.selectAll();
        List<DynamicFieldsVO> vos=null;
        if (CollectionUtils.isNotEmpty(pos)){
            vos=pos.stream().map(po->{
                DynamicFieldsVO vo=new DynamicFieldsVO();
                BeanUtils.copyProperties(po,vo);
                return vo;
            }).collect(Collectors.toList());
        }
        return vos;
    }
}
